<template>
  <div>
    <el-select
        v-model="databaseId"
        placeholder="请选择"
        size="mini"
    >
      <el-option
          v-for="(item,index) in databases"
          :key="index"
          :label="item.name"
          :value="item.id"
      >
      </el-option>
    </el-select>

    <el-button
        :loading="doing"
        plain
        size="mini"
        type="primary"
        @click="onQueryClick"
    >执行
    </el-button>
  </div>
</template>
<script>
export default {
  props: {
    databases: [Array],
    doing: Boolean,
  },
  data() {
    return {
      databaseId: null,
    };
  },
  watch: {
    databases(list) {
      if (this.databaseId == null && list.length > 0) {
        this.databaseId = list[0].id;
      }
    },
  },
  methods: {
    onQueryClick() {
      this.$emit("query", this.databaseId);
    },
  },
};
</script>
    